/*
 * Created by SharpDevelop.
 * User: rseward
 * Date: 6/4/2008
 * Time: 2:10 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;

namespace AvvaMobileNHibernateHelperKit
{
	/// <summary>
	/// A Name formatter that transform DB names to CamelCase CamelCaseNameFormatter.
	/// </summary>
	public class CamelCaseNameFormatter : INameFormatter
	{
		public CamelCaseNameFormatter()
		{
		}
		
		public string GetClassName(string dbTableName)
		{
			string className = NameUtils.CamelifyName( dbTableName );
			className  = NameUtils.Capitalize( className );
			
			return className;
		}
		
		public string GetFieldName(string className, string dbColName)
		{
			string fieldName = NameUtils.CamelifyName( dbColName );
			fieldName = NameUtils.Uncapitalize( fieldName );
			
			if (className.Equals( fieldName) ) {
				fieldName = NameUtils.GetPropertyName( className, fieldName );
			}
			
			return fieldName;
		}
		
		public string GetPropertyName(string className, string dbColName)
		{
			string propName = NameUtils.CamelifyName( dbColName );
			propName = NameUtils.Capitalize( propName );
			
			if (className.Equals( propName) ) {
				propName = NameUtils.GetPropertyName( className, propName);
			}
			
			return propName;
		}
		
	}
}
